package com.tsunami.authority.entity.auth;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.tsunami.authority.enums.auth.AuthorizeType;
import com.tsunami.base.entity.SuperEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import lombok.experimental.Accessors;

import java.io.Serial;
import java.time.LocalDateTime;

/**
 * <p>
 * 角色权限关系表
 * </p>
 *
 * @author lx
 * @since 2021-09-23
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@ToString(callSuper = true)
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@TableName("tnm_auth_role_authority")
@Schema(description = "角色的权限资源")
public class RoleAuthority extends SuperEntity<Long> {

    @Serial
    private static final long serialVersionUID = 1L;

    @Schema(description = "租户号")
    @TableField(value = "tenant_id")
    private Long tenantId;

    @Schema(description = "权限ID")
    @TableField(value = "authority_id")
    private Long authorityId;

    @Schema(description = "权限类型;MENU:菜单 RESOURCE:资源")
    @TableField(value = "authority_type")
    private AuthorizeType authorityType;

    @Schema(description = "角色ID")
    @TableField(value = "role_id")
    private Long roleId;

    @Builder
    public RoleAuthority(Long id, LocalDateTime createTime, Long createUser,
                         Long authorityId, AuthorizeType authorityType, Long roleId) {
        this.id = id;
        this.createTime = createTime;
        this.createUser = createUser;
        this.authorityId = authorityId;
        this.authorityType = authorityType;
        this.roleId = roleId;
    }
}
